<template>
  <van-goods-action>
    <!--取反如果ifSave为真就点亮收藏按钮-->
    <van-goods-action-icon
      :icon="ifSave ? 'star' : 'star - o'"
      :text="ifSave ? '已收藏' : '未收藏'"
      :color="ifSave ? 'darkred' : '#666'"
      @click="Save"
    />
    <van-goods-action-icon icon="cart-o" text="购物车" :badge="badge" />
    <van-goods-action-button type="danger" text="立即购买" @click="buyNow" />
    <van-goods-action-button type="warning" text="加入购物车" @click="addToCart"/>
  </van-goods-action>
</template>

<script>
export default {
  data() {
    return {
      ifSave: false,
    };
  },
  props:['badge'],
  methods: {
    buyNow() {
      this.$toast("该功能暂未开发");
    },
    Save(){
        // 点击的时候取反
        this.ifSave=!this.ifSave
    },
    // 点击加入购物车
    addToCart(){
      this.$emit('addToCart')
    }
  },
  created(){
    
  }
};
</script>
<style scoped></style>
